// 统一管理用户相关的接口
import request from "@/utils/request";
import { SubjectRoleInfo, UpdateRoleForm, RemoveRoleForm, Mamber, SetChairmanForm } from "./type";
// 统一管理接口
enum API {
    GETAUTHORITY_URL = "/need/role/getRoleAuthority",
    GETROLELIST_URL = "/need/role/getRoleList",
    ADDROLE_URL = "/need/role/addRole",
    REMOVEROLE_URL = "/need/role/removeRole",
    UPDATEROLE_URL = "/need/role/updateRole",
    SETCHAIRMAN_URL = "/need/role/setChairman",
    QUIT_URL = "/need/role/quitSubject",
}

// 暴露请求函数
export const reqAuthority = (subjectId: number | string) => {
    return request.post<any, ResponseData<{ authoriyt: number }>>(API.GETAUTHORITY_URL, {
        subjectId,
    });
};
// 获取项目成员列表
export const reqRoleList = (subjectId: number | string) => {
    return request.post<any, ResponseData<Array<SubjectRoleInfo>>>(API.GETROLELIST_URL, { subjectId });
};
// 添加角色
export const reqAddRole = (data: UpdateRoleForm) => {
    return request.post<any, ResponseData>(API.ADDROLE_URL, data);
};
// 删除角色
export const reqRemoveRole = (data: RemoveRoleForm) => {
    return request.post<any, ResponseData>(API.REMOVEROLE_URL, data);
};
// 更新角色权限
export const reqUpdateRole = (data: Mamber) => {
    return request.post<any, ResponseData>(API.UPDATEROLE_URL, data);
};
// 设置负责人
export const reqSetChairman = (data: SetChairmanForm) => {
    return request.post<any, ResponseData>(API.SETCHAIRMAN_URL, data);
};
// 退出课题
export const reqQuitSubject = (data: { subjectId: number }) => request.post<any, ResponseData>(API.QUIT_URL, data);
